/*
Appendix Table 2
Association between Firm-Level Exposure to PSL Mandates and Workers' reports of Access to PSL in non-Mandate Places
*/

cd "$exhibits_path"

use "$data_path/main_analysis_file.dta", clear


* define controls
	global demog i.gender i.race2_harm c.age_text_clean i.kids i.eslhome i.enrolled i.cohabstatus
	global work i.manager i.longwork_yrs i.union c.hourwage_clean c.usualhours_clean 
	global statechars c.unionmem_pc c.unemp_rate  c.minwage_state  	c.race_black c.race_amind c.race_asian c.race_pacisl c.race_other c.race_multi c.hispan c.age_u5 c.age_5to9 c.age_10to14 c.age_75to84 c.age_85plus c.female_pc c.educ_pc_hsgrad c.educ_pc_somecoll c.educ_pc_assoc c.educ_pc_bach c.educ_pc_grad
	global empchars i.shift_ind c.total_emps c.total_ests


******************Workers in Non-PSL States Regressions*************************************



*Demographic Controls
eststo col1row1: mi est, post: reg benefits_paidsick c.pct_emps_psl_state $demog if  psl_law_states_hybd == 0, vce(cluster statelist) 
*eststo t1pAcolB1
eststo col1row2: mi est, post: reg benefits_paidsick c.pct_ests_psl_state $demog if  psl_law_states_hybd == 0, vce(cluster statelist) 
eststo col1row3: mi est, post: reg benefits_paidsick c.pct_emps_psl_place $demog if  psl_law_states_hybd == 0, vce(cluster statelist) 
eststo col1row4: mi est, post: reg benefits_paidsick c.pct_ests_psl_place $demog if  psl_law_states_hybd == 0, vce(cluster statelist) 

*Demographic and Work Controls
eststo col2row1: mi est, post: reg benefits_paidsick c.pct_emps_psl_state $demog $work if  psl_law_states_hybd == 0, vce(cluster statelist) 
eststo col2row2: mi est, post: reg benefits_paidsick c.pct_ests_psl_state $demog  $work if  psl_law_states_hybd == 0, vce(cluster statelist) 
eststo col2row3: mi est, post: reg benefits_paidsick c.pct_emps_psl_place $demog  $work if  psl_law_states_hybd == 0, vce(cluster statelist) 
eststo col2row4: mi est, post: reg benefits_paidsick c.pct_ests_psl_place $demog  $work if  psl_law_states_hybd == 0, vce(cluster statelist) 

*Demographic and Work Controls, Employer Charachteristics
eststo col3row1: mi est, post: reg benefits_paidsick c.pct_emps_psl_state $demog $work $empchars if  psl_law_states_hybd == 0, vce(cluster statelist) 
eststo col3row2: mi est, post: reg benefits_paidsick c.pct_ests_psl_state $demog $work $empchars if  psl_law_states_hybd == 0, vce(cluster statelist) 
eststo col3row3: mi est, post: reg benefits_paidsick c.pct_emps_psl_place $demog $work $empchars if  psl_law_states_hybd == 0, vce(cluster statelist) 
eststo col3row4: mi est, post: reg benefits_paidsick c.pct_ests_psl_place $demog $work $empchars if  psl_law_states_hybd == 0, vce(cluster statelist) 

*Demographic and Work Controls, Employer and State Charachteristics
eststo col4row1: mi est, post: reg benefits_paidsick c.pct_emps_psl_state $demog $work $empchars $statechars  if  psl_law_states_hybd == 0, vce(cluster statelist) 
eststo col4row2: mi est, post: reg benefits_paidsick c.pct_ests_psl_state $demog $work $empchars $statechars  if  psl_law_states_hybd == 0, vce(cluster statelist) 
eststo col4row3: mi est, post: reg benefits_paidsick c.pct_emps_psl_place $demog $work $empchars $statechars if  psl_law_states_hybd == 0, vce(cluster statelist) 
eststo col4row4: mi est, post: reg benefits_paidsick c.pct_ests_psl_place $demog $work $empchars $statechars if  psl_law_states_hybd == 0, vce(cluster statelist) 


*Demographic and Work Controls, Employer and State Charachteristics, State Fixed Effects
eststo col5row1: mi est, post: reg benefits_paidsick c.pct_emps_psl_state $demog $work $empchars $statechars i.statelist if  psl_law_states_hybd == 0, vce(cluster statelist) 
eststo col5row2: mi est, post: reg benefits_paidsick c.pct_ests_psl_state $demog $work $empchars $statechars i.statelist if  psl_law_states_hybd == 0, vce(cluster statelist) 
eststo col5row3: mi est, post: reg benefits_paidsick c.pct_emps_psl_place $demog $work $empchars $statechars i.statelist if  psl_law_states_hybd == 0, vce(cluster statelist) 
eststo col5row4: mi est, post: reg benefits_paidsick c.pct_ests_psl_place $demog $work $empchars $statechars i.statelist if  psl_law_states_hybd == 0, vce(cluster statelist) 

*Demographic and Work Controls, Employer and State Charachteristics, State Fixed Effects, Year Fixed Effects 
eststo col6row1: mi est, post: reg benefits_paidsick c.pct_emps_psl_state $demog $work $statechars $empchars i.statelist i.year##i.month if  psl_law_states_hybd == 0, vce(cluster statelist)
eststo col6row2: mi est, post: reg benefits_paidsick c.pct_ests_psl_state $demog $work $statechars $empchars i.statelist i.year##i.month if  psl_law_states_hybd == 0, vce(cluster statelist) 
eststo col6row3: mi est, post: reg benefits_paidsick c.pct_emps_psl_place $demog $work $statechars $empchars i.statelist i.year##i.month if  psl_law_states_hybd == 0, vce(cluster statelist) 
eststo col6row4: mi est, post: reg benefits_paidsick c.pct_ests_psl_place $demog $work $statechars $empchars i.statelist i.year##i.month if  psl_law_states_hybd == 0, vce(cluster statelist)



*************************Workers in non-PSL States or Counties Regressions****************************

*Demographic Controls
eststo col7row1: mi est, post: reg benefits_paidsick c.pct_emps_psl_state $demog if  psl_law_places_hybd == 0, vce(cluster statelist) 
eststo col7row2: mi est, post: reg benefits_paidsick c.pct_ests_psl_state $demog if  psl_law_places_hybd == 0, vce(cluster statelist) 
eststo col7row3: mi est, post: reg benefits_paidsick c.pct_emps_psl_place $demog if  psl_law_places_hybd == 0, vce(cluster statelist) 
eststo col7row4: mi est, post: reg benefits_paidsick c.pct_ests_psl_place $demog if  psl_law_places_hybd == 0, vce(cluster statelist) 

*Demographic and Work Controls
eststo col8row1: mi est, post: reg benefits_paidsick c.pct_emps_psl_state $demog $work if  psl_law_places_hybd == 0, vce(cluster statelist) 
eststo col8row2: mi est, post: reg benefits_paidsick c.pct_ests_psl_state $demog  $work if  psl_law_places_hybd == 0, vce(cluster statelist) 
eststo col8row3: mi est, post: reg benefits_paidsick c.pct_emps_psl_place $demog  $work if  psl_law_places_hybd == 0, vce(cluster statelist) 
eststo col8row4: mi est, post: reg benefits_paidsick c.pct_ests_psl_place $demog  $work if  psl_law_places_hybd == 0, vce(cluster statelist) 

*Demographic and Work Controls, Employer Charachteristics
eststo col9row1: mi est, post: reg benefits_paidsick c.pct_emps_psl_state $demog $work $empchars if  psl_law_places_hybd == 0, vce(cluster statelist) 
eststo col9row2: mi est, post: reg benefits_paidsick c.pct_ests_psl_state $demog  $work $empchars if  psl_law_places_hybd == 0, vce(cluster statelist)
eststo col9row3: mi est, post: reg benefits_paidsick c.pct_emps_psl_place $demog  $work $empchars if  psl_law_places_hybd == 0, vce(cluster statelist) 
eststo col9row4: mi est, post: reg benefits_paidsick c.pct_ests_psl_place $demog  $work $empchars if  psl_law_places_hybd == 0, vce(cluster statelist)

*Demographic and Work Controls, Employer and State Charachteristics
eststo col10row1: mi est, post: reg benefits_paidsick c.pct_emps_psl_state $demog $work $empchars $statechars if  psl_law_places_hybd == 0, vce(cluster statelist) 
eststo col10row2: mi est, post: reg benefits_paidsick c.pct_ests_psl_state $demog  $work $empchars $statechars  if  psl_law_places_hybd == 0, vce(cluster statelist) 
eststo col10row3: mi est, post: reg benefits_paidsick c.pct_emps_psl_place $demog  $work $empchars $statechars if  psl_law_places_hybd == 0, vce(cluster statelist) 
eststo col10row4: mi est, post: reg benefits_paidsick c.pct_ests_psl_place $demog  $work $empchars $statechars if  psl_law_places_hybd == 0, vce(cluster statelist) 

*Demographic and Work Controls, Employer and State Charachteristics, State Fixed Effects
eststo col11row1: mi est, post: reg benefits_paidsick c.pct_emps_psl_state $demog $work $empchars $statechars i.statelist if psl_law_places_hybd == 0, vce(cluster statelist) 
eststo col11row2: mi est, post: reg benefits_paidsick c.pct_ests_psl_state $demog $work $empchars $statechars i.statelist  if  psl_law_places_hybd == 0, vce(cluster statelist) 
eststo col11row3: mi est, post: reg benefits_paidsick c.pct_emps_psl_place $demog $work $empchars $statechars i.statelist if  psl_law_places_hybd == 0, vce(cluster statelist) 
eststo col11row4: mi est, post: reg benefits_paidsick c.pct_ests_psl_place $demog $work $empchars $statechars i.statelist  if  psl_law_places_hybd == 0, vce(cluster statelist) 

*Demographic and Work Controls, Employer and State Charachteristics, State Fixed Effects, Year Fixed Effects 
eststo col12row1: mi est, post: reg benefits_paidsick c.pct_emps_psl_state $demog $work $statechars $empchars i.statelist i.year##i.month if  psl_law_places_hybd == 0, vce(cluster statelist)
eststo col12row2: mi est, post: reg benefits_paidsick c.pct_ests_psl_state $demog $work $statechars $empchars i.statelist i.year##i.month if  psl_law_places_hybd == 0, vce(cluster statelist) 
eststo col12row3: mi est, post: reg benefits_paidsick c.pct_emps_psl_place $demog $work $statechars $empchars i.statelist i.year##i.month if  psl_law_places_hybd == 0, vce(cluster statelist) 
eststo col12row4: mi est, post: reg benefits_paidsick c.pct_ests_psl_place $demog $work $statechars $empchars i.statelist i.year##i.month if  psl_law_places_hybd == 0, vce(cluster statelist) 




***********
**** EXPORT 
***********

*Labels for sections of latex tables
label var pct_emps_psl_state "\hspace{0.5cm} Percent of Workers"
label var pct_ests_psl_state "\hspace{0.5cm} Percent of Establishments"
label var pct_emps_psl_place "\hspace{0.5cm} Percent of Workers"
label var pct_ests_psl_place "\hspace{0.5cm} Percent of Establishments"

*Local macros for control labels
estadd local DCchecka "\checkmark": col1row4 col2row4 col3row4 col4row4 col5row4 col6row4 col7row4 col8row4 col9row4 col10row4 col11row4 col12row4
estadd local WCchecka "\checkmark": col2row4 col3row4 col4row4 col5row4 col6row4 col8row4 col9row4 col10row4 col11row4 col12row4
estadd local STATEchecka "\checkmark": col3row4 col4row4 col5row4 col6row4  col9row4 col10row4 col11row4 col12row4
estadd local YEARcheckb "\checkmark": col4row4 col5row4 col6row4   col10row4 col11row4 col12row4
estadd local SCchecka  "\checkmark": col5row4 col6row4 col11row4 col12row4
estadd local INDchecka "\checkmark":  col6row4  col12row4

*Code to write latex table
esttab col1row1 col2row1 col3row1 col4row1 col5row1 col6row1 col7row1 col8row1 col9row1 col10row1 col11row1 col12row1 using "$exhibits_path/Appendix Table 2.tex", ///
	prehead("{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} \begin{tabular}{l*{12}{c}} \hline\hline") ///
	fragment keep(*psl*) ///
	 eqlabels(none) mtitles("M1" "M2" "M3" "M4" "M5" "M6" "M7" "M8" "M9" "M10" "M11" "M12") noomitted noconstant nonumbers nonote noobs not nodepvars  label b(%9.3f) ///
	 refcat(pct_emps_psl_state "\textit{Share in a PSL Covered State}", nolabel) ///
	 star(+ 0.10 * 0.05 ** 0.01 *** 0.001) ///
	 	 mgroups("\shortstack{ \\ Panel A: Workers in non-PSL States} " "\shortstack{\\ Panel B: Workers in non-PSL States or Counties}", pattern(1 0 0 0 0 0 1 0 0 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
	replace 
	 
esttab col1row2 col2row2 col3row2 col4row2 col5row2 col6row2 col7row2 col8row2 col9row2 col10row2 col11row2 col12row2 using "$exhibits_path/Appendix Table 2.tex", ///
	fragment keep(*psl*) b(%9.3f) ///
	nomtitles eqlabels(none) noomitted noconstant not nonote noobs  nodepvars nonumbers nolines label /// 
	star(+ 0.10 * 0.05 ** 0.01 *** 0.001) ///
	append
	
esttab col1row3 col2row3 col3row3 col4row3 col5row3 col6row3 col7row3 col8row3 col9row3 col10row3 col11row3 col12row3 using "$exhibits_path/Appendix Table 2.tex", ///
	fragment keep(*psl*) b(%9.3f) ///
	nomtitles eqlabels(none) noomitted noconstant not nonote noobs  nodepvars nonumbers nolines label /// 
	 refcat(pct_emps_psl_place "\vspace{0.1em} \\ \textit{Share in a PSL Covered State or County}" , nolabel) ///
	 star(+ 0.10 * 0.05 ** 0.01 *** 0.001) ///
	append	
	
esttab col1row4 col2row4 col3row4 col4row4 col5row4 col6row4 col7row4 col8row4 col9row4 col10row4 col11row4 col12row4 using "$exhibits_path/Appendix Table 2.tex", ///
	fragment keep(*psl*) ///
	postfoot("\hline\hline \multicolumn{9}{l}{\footnotesize \sym{+} \(p<0.10\), \sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)}\\ \end{tabular} } ") ///
	nomtitles eqlabels(none) noomitted noconstant not nonote noobs  nodepvars nonumbers nolines label b(%9.3f) /// 
	scalars("DCchecka Demographic Controls" "WCchecka Work Controls" "STATEchecka State FE" "YEARcheckb Year, Month, Year $\times$ Month FE" "SCchecka State Controls" " INDchecka Firm Controls" "line \hline \\ \vspace{-2em}" "N N") ///
	sfmt(%9.0f) ///
	prefoot("\vspace{0.1em} \\") ///
	star(+ 0.10 * 0.05 ** 0.01 *** 0.001) ///
	append